package com.example.deal.broker.config;

import javax.servlet.Servlet;

import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;

/**
 * SpringCould 2.0+需要为HystrixMricsStreamServlet手动注入到ServletRegistrationBean中
 * @author Administrator
 *
 */
@Component
public class HystrtixStreamServlet {
	
	@Bean
	public ServletRegistrationBean<Servlet> getSerlvet(){
		HystrixMetricsStreamServlet streamServlet = new HystrixMetricsStreamServlet();
		ServletRegistrationBean<Servlet> registrationBean =  new ServletRegistrationBean<>(streamServlet);
		registrationBean.setLoadOnStartup(1);
		registrationBean.addUrlMappings("/hystrix.stream");
		//registrationBean.addUrlMappings("/hystrix");
		registrationBean.setName("HystrixMricsStreamServlet");
		return registrationBean;
	}
}
